package com.powerrich.serviceImpl;

import com.powerrich.mapper.VipMapper;
import com.powerrich.pojo.VipPO;
import com.powerrich.service.VipService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 黄雨
 * @title: VipServiceImpl
 * @projectName demo
 * @description: TODO
 * @date 2019-04-0414:12
 */
@Service
public class VipServiceImpl implements VipService {

    @Autowired
    private VipMapper vipMapper;

    @Autowired
    private RedisTemplate<String ,Object> redisTemplate;

    @Override
    public VipPO getVipById(Integer id) {
        VipPO vipPO = vipMapper.getVipById(id);
        String ids = id.toString();
        redisTemplate.opsForHash().put("VipPO",ids ,vipPO);
        return vipPO;
    }

    @Override
    public void addVip(VipPO vipPO) {
        vipMapper.addVip(vipPO);
    }

    @Override
    public void updateVip(VipPO vipPO) {
        vipMapper.updateVip(vipPO);
    }

    @Override
    public void deleteVipById(Integer id) {
        vipMapper.deleteVipById(id);
    }

    @Override
    public List<VipPO> getAllVip() {
        return vipMapper.getAllVip();
    }
}
